# 通讯录
from selenium.webdriver.common.by import By

from test_pytest.Utils.log_util import logger
from wxweb_po.package.basedriver import BaseDriver


class ContactPage(BaseDriver):

    def add_member(self):
        # 如果遇到跳转闭环，可将import放在方法体内
        from wxweb_po.package.edit_member import EditMember
        logger.info("点击添加成员按钮")
        # 设置显示等待
        wait_element = (By.ID, "username")  # 想要得到的界面的元素
        click_element = (By.CSS_SELECTOR, ".ww_operationBar .js_add_member")  # 要点击的元素
        self.wait_elements(click_element, wait_element, 10)
        # 跳转到成员信息编辑界面
        return EditMember(self._driver)

    def get_toast(self):
        logger.info("获取toast")
        # 获取保存成功的动画
        ele = self.find(By.CSS_SELECTOR, ".ww_tip.success")
        # 返回
        return ele
